package com.zgl.hello;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.graphics.Color;
import android.os.Handler;
import android.widget.TextView;
import android.os.Message;

public class Activity_framelayout extends Activity{
	private int currentColor = 0;
	final int[] colors = new int[]{Color.BLACK, Color.WHITE, Color.CYAN, Color.BLUE, Color.DKGRAY, Color.GREEN};
	final int[] names = new int[]{R.id.view1, R.id.view2, R.id.view3, R.id.view4, R.id.view5, R.id.view6};
	
	TextView[] views = new TextView[names.length];
	Handler handler = new Handler(){
		@Override
		public void handleMessage(Message msg) {
			if(msg.what == 0x123){
				for(int i = 0; i < names.length; i++){
					views[i].setBackgroundColor(colors[(i + currentColor) % names.length]);
				}
				currentColor++;
			}
			super.handleMessage(msg);
		}
	};
	
	protected void onCreate(android.os.Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_framelayout);
		
		for(int i = 0; i < names.length; i++){
			views[i] = (TextView)findViewById(names[i]);
		}
		
		//瀹氫箟涓�釜绾跨▼鍛ㄦ湡鎬у湴鏀瑰彉currentColor鍙橀噺鍊�	
		
		new Timer().schedule(new TimerTask() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				handler.sendEmptyMessage(0x123);
			}
		}, 0, 200);
	};
	
}
